#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QHBoxLayout>
#include <QSplitter>
#include <QApplication>
#include <QTextBrowser>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // 整体用水平布局
    QHBoxLayout* pHLay = new QHBoxLayout(this);

    // 整体的水平分裂器
    QSplitter* pHSplitter = new QSplitter(Qt::Horizontal, this); // 头函数是 QApplication
    QWidget* pLeftWidget = new QWidget(this);
    pLeftWidget->setStyleSheet("background-color:rgb(54, 54, 54)");
    pLeftWidget->setMinimumWidth(200);

    // 分裂期添加 Widget
    pHSplitter->addWidget(pLeftWidget);

    // 右侧竖直分裂器，注意参数 pHSplitter，表示父指针
    QSplitter* pVSplitter = new QSplitter(Qt::Vertical, pHSplitter);


    // 拖到到位后，先弹起鼠标再显示分割条
    pVSplitter->setOpaqueResize(false); // 设定分割条是实时更新，false 表示拖拽时显示灰色粗线条

    QWidget* pRightTopWidget = new QWidget(this);
    pRightTopWidget->setStyleSheet("background-color:rgb(154, 154, 154)");

    QTextBrowser* pRightBottom = new QTextBrowser(this);

    pVSplitter->addWidget(pRightTopWidget);
    pVSplitter->addWidget(pRightBottom);

    pHSplitter->addWidget(pVSplitter);

    pHLay->addWidget(pHSplitter);
    this->setLayout(pHLay);
}

Widget::~Widget()
{
    delete ui;
}
